package com.android.equipment.base;

import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.core.view.WindowCompat;
import androidx.core.view.WindowInsetsCompat;
import androidx.core.view.WindowInsetsControllerCompat;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;

import com.gyf.immersionbar.ImmersionBar;




public abstract class BaseFragment extends Fragment {
    protected View layoutView;
    protected FragmentActivity mContext;
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (layoutView == null) {
            layoutView = setLayoutContent(inflater,container);

        }
        ViewGroup viewGroup = (ViewGroup) layoutView.getParent();
        if (viewGroup != null) {
            viewGroup.removeView(layoutView);
        }
        mContext = getActivity();

//        assert mContext != null;
//        WindowInsetsControllerCompat controller = WindowCompat.getInsetsController(mContext.getWindow(), layoutView);
//        controller.hide(WindowInsetsCompat.Type.systemBars());

        initView(savedInstanceState, layoutView);
        initEvent();
        initData();
        return layoutView;
    }






    protected abstract View setLayoutContent(LayoutInflater inflater, ViewGroup container);



    /**
     * 初始化View
     */
    protected abstract void initView(Bundle savedInstanceState, View view);

    protected void initEvent(){
    }
    /**
     * 数据加载
     */
    protected abstract void initData();

    @Override
    public void onResume() {
        super.onResume();

    }






}